<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .box {
            width: 368px;
            height: 220px;
            position: relative;
        }
        .footer {
            height: 40px;
            background-color: rgba(0,0,0,0.7);
            position: absolute;
            bottom: 0px;
            width: 368px;
            line-height: 40px;
            font-size: 14px;
        }
        .footer .txt {
            padding-left: 10px;
            font-weight: bold;
        }
        .footer .txt a {
            color: white;
            text-decoration: none;
        }
        .footer .links {
            position: absolute;
            top:0px;
            right: 5px;

        }
        .footer .links a {
            background-color: rgb(124, 121, 122);
            padding: 1px 4px;
            text-decoration: none;
            color: white;
            margin-right: 1px;
        }
        .footer .links .active {
            background-color: rgb(212, 87, 7);
        }
    </style>
</head>
<body>
<h2>asdafsdafdsafsadasdffasdffdsafdsaasdffasd</h2>
<h2>asdafsdafdsafsadasdffasdffdsafdsaasdffasd</h2>
<h2>asdafsdafdsafsadasdffasdffdsafdsaasdffasd</h2>
<div class="box" id="box">
    <img src="image/1.jpg" style="display: block">
    <img src="image/2.png" style="display: none">
    <img src="image/3.jpg" style="display: none">
    <img src="image/4.jpg" style="display: none">
    <img src="image/5.jpg" style="display: none">
    <div class="footer">
        <div class="txt"><a href="#">十问十答合肥高温天气那些事</a> </div>
        <div class="links">
            <a href="#"  class="active">1</a><a href="#">2</a><a href="#" >3</a><a href="#">4</a><a href="#" >5</a>
        </div>
    </div>
</div>

<h2>asdafsdafdsafsadasdffasdffdsafdsaasdffasd</h2>
<h2>asdafsdafdsafsadasdffasdffdsafdsaasdffasd</h2>
<h2>asdafsdafdsafsadasdffasdffdsafdsaasdffasd</h2>
<script>
    var box = document.getElementById('box');   //找到box元素
    var imgs = box.getElementsByTagName('img'); //找到box元素下的所有 img标签 类似数组 HtmlConllection 集合对象
    console.log(imgs);


    var nowIndex = 0;
    function doSwitch(){
        //让图片重新开始
        if (nowIndex>=imgs.length){
            nowIndex = 0;
        }
        //隐藏全部图片
        for(var i = 0;i<imgs.length;i++){
            imgs[i].style.display = 'none';
        }

        //显示当前图片
        imgs[nowIndex].style.display = 'block';


        imgs[nowIndex].style.opacity = 0.1;
        var k = 0.1;
        function feadIn(){
            k = k+0.1;
            if (k >=1){
                clearInterval(timeFeadIn);
            }
            imgs[nowIndex].style.opacity = k;


        }
        var timeFeadIn = setInterval(feadIn,100);



        nowIndex++;
    }

    setInterval(doSwitch,1000);



</script>
</body>
</html>